/*
ID: icerupt1
PROG: fact4
LANG: C++11
*/

/* solution
 *
 *
 *
*/
#include <fstream>
#include <iostream>

std::ifstream fin {"fact4.in" };
std::ofstream fout{"fact4.out"};

int n, ans = 1;
int count5;

int main()
{
	fin >> n;
	for (int i = 2; i <= n; i++)
		for (int t = i; !(t % 5); t /= 5) count5++;

	int count2 = count5;
	for (int i = 2; i <= n; i++) {
		int t = i;
		for (; !(t % 2) && count2; t /= 2) count2--;
		for (; !(t % 5) && count5; t /= 5) count5--;
		ans = (ans * t) % 10;
	}
	std::cout << ans << '\n';
	fout << ans << '\n';
}

